<template>
<div style="height:100%">
  <div class="buttonarea">
    <label>选择时间</label>
    <el-radio-group v-model="radio" style="margin:12px" @change="changeoption">
    <el-radio :label="0">全部</el-radio>
    <el-radio :label="3">近3天</el-radio>
    <el-radio :label="7">近一周</el-radio>
    <el-radio :label="30">近一月</el-radio>
  </el-radio-group>
  </div>
  <div>
     
  <el-table
    :data="tableData2"
    style="width: 100%"
    max-height="600">
  <el-table-column
    fixed
     align="center"
      label="保单号"
      prop="orderid"
     >
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="流水号"
      prop="id"
     >
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="交易时间"
      :formatter="formattime"
      prop="tday">
      
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="收入"
      prop="income">
          <template  slot-scope="scope">
      {{scope.row.yuedirection==0?(scope.row.yuedirection==1?Math.round(scope.row.expend*100)/100:Math.round(scope.row.income*100)/100):''}}

      </template>
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="支出"
      prop="expend">
          <template  slot-scope="scope">
      {{scope.row.yuedirection==1?(scope.row.yuedirection==1?Math.round(scope.row.expend*100)/100:Math.round(scope.row.income*100)/100):''}}

      </template>
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="账户余额"
      prop="yuealter">
          <template  slot-scope="scope">
      {{ Math.round(scope.row.yuealter*100)/100}}

      </template>
    </el-table-column>
    <el-table-column
       prop="comment"
       label="交易类别"
      width="100">
        <template slot-scope="scope">
        {{scope.row.comment}}
      </template>
    </el-table-column>
    <el-table-column
       prop="description"
       label="备注"
      width="100">
    </el-table-column>
    <el-table-column
    fixed
     align="center"
      label="状态"
      prop="status"
     >
     已完成
    </el-table-column>
  </el-table>

  <el-dialog
  title="欢迎使用优保旅行信息平台"
  :visible.sync="tzshow"
  width="50%"
  :before-close="handleClose">
  <span>这是一段信息</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="tzshow = false">取 消</el-button>
    <el-button type="primary" @click="tzshow = false">确 定</el-button>
  </span>
</el-dialog>
  
 <div class="block">
       <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="page"
      :page-size="10"
      background
      layout="total, prev, pager, next"
      :total="total">
    </el-pagination>
  </div> 
  </div>
  </div>
</template>

<script>
import {gettrans, getmembers,unlockmember,stopmember } from '@/api/policy'


export default {
  name: 'flow',
  components: { },
    computed: {
  },
  data() {
    return {
      begintime:0,
      endtime:0,
      user:{},
      radio: 0,
      page:1,
      size:10,
      status:'',
      total:0,
      input5:'',
      select:'0',
      tzshow:false,
      typevalue:'0',
      state:'0',
      searchtag:"0",
    tableData: [],
    tableData2:[
      // {
      //   id:'3242342342',
      //   flowid:'123123123',
      //   time:'2020-01-02 18:00',
      //   income:'',
      //   pay:'1000.00',
      //   yuealter:'1000.00',
      //   type:'充值',
      //   beizhu:'',
      //   status:'已完成',

      // }
    ],


    }
      
  },
  components:{


  },
  mounted(){
  this.user=JSON.parse(localStorage.getItem('user'))
      //  this.getbalance();
       this.gettrans();
       

  },
  methods:{
     formattime(row) {
       var dt=row.tday;
        var date = new Date(dt);
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    },

    handleClose(){

    },

     
changeoption(e){
    if(e!=0)
    {


     this.endtime=new Date().getTime()+60000;
     this.begintime=this.endtime-86400000*e;





    }
    else
    {
      this.begintime=0;
      this.endtime=0;
    }
    this.gettrans();
},



     gettrans(id){
  this.$loadingshow();
var dt={};










dt={

 organid: this.user.organid ,
page: this.page,
size: this.size,
branch: true,
begintime: this.begintime,
endtime: this.endtime,
}

       gettrans(dt ).then(res => {
         this.$loadingclose();
        if (res.code == 200) {
        
               this.tableData2=res.result;
               if(res.result.length>0)
               this.total=res.result[0].total;
        } 
        else{
          this.$toast(res.message)
        }
      });
    },
     addlead(){
    this.$router.push("addleadofself")
  },
    gosearch()
    {
    this.page=1;
    this.total=0;
    this.searchtag=1;
    this.getmembers();



    },
      reset()
    {
    this.page=1;
    this.total=0;
    this.searchtag=0;
    this.getmembers();



    },
         getNowFormatDate(dt) {
        var date = new Date(dt);
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    },
      getmembers(){

this.$loadingshow();
       getmembers({ page:this.page,searchtag:this.searchtag,size:10,customertype:this.typevalue,key:this.select,keyword:this.input5,key2:this.state }).then(res => {
              this.$loadingclose();
       if (res.code == 200) {
              this.tableData=res.result.list;
              this.total=res.result.total;
              for(var i=0;i<this.tableData.length;i++)
              {
                   this.tableData[i].index=i;
                   this.tableData[i].typedesc=this.tableData[i].type==1?'重点':'普通'
                   

              }
           //   document.getElementsByClassName('el-table__body-wrapper')[0].style.height='auto';
        } 
        else{
          this.$toast(res.message)
        }
      });
    },
    addcustomer(){
      this.$router.push('addcustomer');
    },
    genjin(row){
      this.$router.push('genjin?id='+row.id+'&name='+row.username);
    },
    toadd(value){
    // this.$router.push('addpolicy');
    window.open('http://chudan.zhiyuewulian.com');
    },
    filterTag(){

    },
handleSizeChange(){

},
convert(status)
{
     if(status==1)
               {
status= '新客户';

               }
               if(status==2)
               {
status= '沟通中';

               }
                         if(status==3)
               {
status= '有意向';

               }
              if(status==4)
               {
status= '成交几率高';

               }
                         if(status==5)
               {
status= '即将购买';

               }
                         if(status==6)
               {
status= '完成购买';

               }
                         if(status==7)
               {
status= '无意向';

               }
                          if(status==8)
               {
status= '已解锁';

               }
               return status;
},
handleCurrentChange(){
     this.gettrans();
},
handleClick(id,index) {
        //this.$router.push('chakan');
        this.$loadingshow();
       unlockmember({id:id }).then(res => {
           this.$loadingclose();
        if (res.code == 200) {
          this.tableData[index].status=8;
          this.$toast('解锁成功')
        } 
        else{
          this.$toast(res.message)
        }
      });
      },
      handleClickread(row) {
        this.$router.push('chakan?id='+row.id);
      },
      stopmember(id,index){

       this.$loadingshow();
       stopmember({id:id }).then(res => {
           this.$loadingclose();
        if (res.code == 200) {
          this.tableData[index].status=3;
          this.$toast('停止成功')
        } 
        else{
          this.$toast(res.message)
        }
      });


      }
  }
}
</script>

<style lang="scss" scoped>
.buttonarea{
  width:90%;
  padding: 20px;
  // height: 50px;
}
.btn{
  position: relative;
    /* left: 73%; */
    float: right;
    right: 9px;
    margin-top: 6px;
}
.block{
      text-align: center;
      margin-top:10px;
}

.documentation-container {
  // margin: 50px;
  .document-btn {
    float: left;
    margin-left: 50px;
    display: block;
    cursor: pointer;
    background: black;
    color: white;
    height: 60px;
    width: 200px;
    line-height: 60px;
    font-size: 20px;
    text-align: center;
  }
}
   .popstyle{
        width: 100%;
        height: 30%;
    }
    .userfile{
    width: 90px;
    height: 30px;
    background: cornflowerblue;
    font-size: 14px;
    color: #fff;
    line-height: 30px;
    border-radius: 10px;
    text-align: center;
    margin: 0 auto;
    margin-top: 20px;
}
/deep/  .el-input--suffix .el-input__inner{
  width:150px;
}
/deep/ .el-form-item{
  width: 20%;
}
</style>
